import { ColumnsType } from "@/components"

export enum TableLabel {
    Id = "Id",
    ShopCode = "店铺编码",
    ShopName = "店铺名称",
    Ymd = "日期号",
    DataMonth = "月期号",
    DineIn = "堂食订单数",
    DineInAmount = "堂食订单金额",
    Takeaway = "外卖订单数",
    TakeawayAmount = "外卖订单金额",
    OrderAmount = "总金额",
    CreatedAt = "创建时间",
    UpdatedAt = "更新时间",
    Range = "时间范围"
}

/**
 * 报表类型 字段
 */
export enum ReportLabel {
    日报表 = "SelectDaily",
    月报表 = "SelectMonthly",
    总报表 = "SelectTotal",
}

// 全部列配置 数据
const TableConfig: Record<string, ColumnsType> = {
    Id: {
        minWidth: 100,
        label: TableLabel.Id,
        prop: "Id"
    },
    ShopCode: {
        minWidth: 120,
        label: TableLabel.ShopCode,
        prop: "ShopCode"
    },
    ShopName: {
        minWidth: 120,
        label: TableLabel.ShopName,
        prop: "ShopName"
    },
    DineIn: {
        minWidth: 120,
        label: TableLabel.DineIn,
        prop: "DineIn"
    },
    DineInAmount: {
        minWidth: 140,
        label: TableLabel.DineInAmount,
        prop: "DineInAmount"
    },
    Takeaway: {
        minWidth: 140,
        label: TableLabel.Takeaway,
        prop: "Takeaway"
    },
    TakeawayAmount: {
        minWidth: 140,
        label: TableLabel.TakeawayAmount,
        prop: "TakeawayAmount"
    },
    OrderAmount: {
        minWidth: 140,
        label: TableLabel.OrderAmount,
        prop: "OrderAmount"
    },
    Ymd: {
        width: 180,
        DateFormat: true,
        sortable: true,
        label: TableLabel.Ymd,
        prop: "Ymd"
    },
    DataMonth: {
        width: 180,
        DateFormat: true,
        sortable: true,
        label: TableLabel.DataMonth,
        prop: "DataMonth",
    },
    CreatedAt: {
        width: 180,
        DateFormat: true,
        sortable: true,
        label: TableLabel.CreatedAt,
        prop: "CreatedAt"
    },
    UpdatedAt: {
        width: 180,
        DateFormat: true,
        sortable: true,
        label: TableLabel.UpdatedAt,
        prop: "UpdatedAt"
    },
}

// 选择指定列 配置数据
const _useColumnsConfig = (keys: (keyof typeof TableConfig)[]) => {
    return keys.map((key) => TableConfig[key])
}

/**
 * 日报表 列配置
 */
export const SelectDailyColumns: ColumnsType[] = [
    ..._useColumnsConfig([
        "Id",
        "ShopCode",
        "ShopName",
        "DineIn",
        "DineInAmount",
        "Takeaway",
        "TakeawayAmount",
        "OrderAmount",
        "Ymd",
        "UpdatedAt",
        "CreatedAt"
    ])
]

/**
 * 月报表 列配置
 */
export const SelectMonthlyColumns: ColumnsType[] = [
    ..._useColumnsConfig([
        "Id",
        "ShopCode",
        "ShopName",
        "DineIn",
        "DineInAmount",
        "Takeaway",
        "TakeawayAmount",
        "OrderAmount",
        "DataMonth",
        "UpdatedAt",
        "CreatedAt"
    ])
]

/**
 * 总报表 列配置
 */
export const SelectTotalColumns: ColumnsType[] = [
    ..._useColumnsConfig([
        "Id",
        "ShopCode",
        "ShopName",
        "DineIn",
        "DineInAmount",
        "Takeaway",
        "TakeawayAmount",
        "OrderAmount",
        "UpdatedAt",
        "CreatedAt"
    ])
]